var myChart = echarts.init(document.getElementById("a1"));
var option = {
    baseOption:{
        timeline:{
            axisType:'category',
            autoPlay:'true',
            playInterval:1000,
            data:['2016','2017','2018','2019','2020']
        },
        title:{
            text:'GDP变化',
            left:'center',

        },
        xAxis:{
            type:'category',
            name:'国家',
            data:['中国','美国','日本','德国','英国'],
        },
        yAxis:{
            name:'GDP',
            min:0,
            max:30,
        },

    },
    options:[{
        series:{
            type:'bar',
            data:[11.23,18.75,5.01,3.47,2.72],
        }
        },{
            series:{
                type:'bar',
                data:[12.31,19.54,4.93,3.68,2.71],
            }
        },{
            series:{
                type:'bar',
                data:[12.89,20.61,5.04,5.51,5.06],
            }
        },{
            series:{
                type:'bar',
                data:[14.28,21.43,5.51,3.89,2.88],
            }
        },{
            series:{
                type:'bar',
                data:[14.72,20.95,5.06,3.85,2.26],
            }
        }],
};
    //画图
myChart.setOption(option);
//----------------------------------------------
var dataTest = []
for(var i=0;i<100;i++){
    var x = Math.floor(100*Math.random());
    var y = Math.floor(100*Math.random());
    dataTest.push([x,y]);
};

var myChart2 = echarts.init(document.getElementById("a2"))
var option2 = {
    xAxis: {},
    yAxis: {},
    title: {
        text: '石子落地位置--沈林涛',
        left: 'center',
    },
    toolbox: {
        bottom: 1,
        feature: {
            saveAsImage: {},
            dataZoom: {},
            dataView: {},
            restore: {},
        },
    },
    series:{
        type:'scatter',
        data:dataTest,
        symbolSize: 5,
 
    },
};
myChart2.setOption(option2);
//----------------------------------------------
var myChart3 = echarts.init(document.getElementById("a3"))
var option3 = {
    title:{
        text:"手机品牌销量对比-沈林涛",
        left: 'center',
    },
    xAxis: {
        type: 'category',
        name:"X",
        data: ["A","B","C","D"],
        
    },
    yAxis: {
        name: "Y",
        min: 100,
        max: 600,
    },
    legend: {
        bottom: 'bottom',
    },
    series: [{
        type:'bar',
        name: '手机销量',
        data: [400,500,400,200],
        label: {
            show: true,
            position: 'top',
        }, 
    },{
        type:'bar',
        name: 'PC销量',
        data: [500,100,200,300],
        label: {
            show: true,
            position: 'top',
            
        }, 
    },{
        type:'bar',
        name: '平板销量',
        data: [450,330,280,390],
        label: {
            show: true,
            position: 'top',
        }, 
        stack: '总量',
    }
  ],
};
myChart3.setOption(option3)
//----------------------------------------------
var myChart4 = echarts.init(document.getElementById("a4"))
var option4 = {
    title: {
        text: '仪表盘-沈林涛',
    },
        series:[{
            type: 'gauge',
            data: [{
                name:' ',
                value: 0
            }],
            min: 0,
            max: 60,
            startAngle: 90,
            endAngle: -270,
            splitNumber:12,
            detail: {
                show: false,
            },
            axisLabel: {
                formatter: function (value){
                    if (value === 0) {
                      return '';
                    }
                    return value + '';
                  }
            },
          },{
            type: 'gauge',
            data: [{
                name:' ',
                value: 0
            }],
            min: 0,
            max: 12,
            startAngle: 90,
            endAngle: -270,
            splitNumber:12,
            detail: {
                show: false,
            },
            axisLabel: {
                // formatter: function (value){
                //     if (value === 0) {
                //       return '';
                //     }
                //     return value + '';
                //   }
                show: false,
            },
          }],
        };
myChart4.setOption(option4);
//----------------------------------------------
var myChart5 = echarts.init(document.getElementById("a5"))
var option5 = {
    title: {
        text: '地图--沈林涛',
    },
    visualMap: {
        max:15,
        min:1,
        range:[2,10],
        inRand:{
            color:['green','yellow']
        },
        calculable:'true',
        top:'bottom',
        left:'center',
        orient:'horizontal',
    },
    series:{
        type:'map',
        map: 'china',
        selectedMode: 'multiple',
        roam: true,
        data: [{
            name: '浙江',
            value: 10,
            label: {
                show: true,
                color:'black',
            },
            itemStyle: {
                areaColor: 'yellow',
            },
        },{
            name: '福建',
            value: 8,
            label: {
                show: true,
            },
        },{
            name: '广东',
            value: 6,
            label: {
                show: true,
            },
            itemStyle: {
                areaColor: 'red',
            },
        },{
            name: '黑龙江',
            value: 4,
            label: {
                show: true,
            },
            itemStyle: {
                areaColor: 'red',
            },
        },{
            name: '四川',
            value: 2,
            label: {
                show: true,
            },
            itemStyle: {
                areaColor: 'red',
            },
        }],
        //boundingCoords: [[-180,90],[180,-90]],
    },
};
myChart5.setOption(option5)

var myChart6 = echarts.init(document.getElementById("a6"))
var option6 = {
    xAxis: {
        name: '日期',
        type: 'category',
        data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
    },
    yAxis: {
        name: '销售量',
        type: 'value',
        // data: [10,20,30,40],
    },
    legend: {
        show: true,
        bottom: 1,
    },
    title: {
        text: '手机销量--沈林涛',
        left: 'center',
    },
    series:[{
        type:'line',
        name: '荣耀销量',
        data:[74,85,57,68,72,47,91],
        label: {
            show: true,
        },
    },{
        type:'bar',
        name: '小米销量',
        data:[85,69,71,25,79,82,80],
        label: {
            show: true,
        },
    }],
};
myChart6.setOption(option6)

var myChart7 = echarts.init(document.getElementById("a7"));
//配置绘图参数
var option7 = {
    grid: [
        {
            top: '5%',  bottom: '55%',
            left: '15%',  right: '55%',
        },
        {
            left: '15%', right: '55%',
            bottom: '5%',   top: '55%',
        },
        {
            left: '55%', right: '15%',
            bottom: '55%',   top: '5%',
        },
        {
            left: '55%', right: '15%',
            bottom: '5%',   top: '55%',
        },
      ],
    xAxis: [{gridIndex: 0, type:'category'},
      {gridIndex: 1, type:'category'},
      {gridIndex: 2, type:'category'},
      {gridIndex: 3,name: '沈林涛', type:'category'}],
    yAxis: [{ gridIndex: 0,},
      {gridIndex: 1,},
      {gridIndex: 2,},
      {gridIndex: 3,}],
      series: [{
          type:'line',
          data:[4,1,9,3],
          xAxisIndex: 1,
          yAxisIndex: 1,
      },{
        type:'line',
        data:[5,2,6,4],
        xAxisIndex: 2,
        yAxisIndex: 2,
    },{
        type:'line',
        data:[6,1,4,7],
        xAxisIndex: 3,
        yAxisIndex: 3,
    },{
        type:'line',
        data:[9,1,7,8],
        xAxisIndex: 0,
        yAxisIndex: 0,
    }],
};
//画图
myChart7.setOption(option7);

var dataSet = [];
for(var i=0;i<100;i++){
    var x = Math.floor(100*Math.random());
    var y = Math.floor(100*Math.random());
    var z = Math.floor(100*Math.random());
    dataSet.push([x,y,z])
}
var myChart8 = echarts.init(document.getElementById("a8"));
var option8 = {
    title: {
        text: '3D散点图形--沈林涛',
    },
        grid3D: {},
        xAxis3D: {},
        yAxis3D: {},
        zAxis3D: {},
        series:[{
            type:'scatter3D',
            data:dataSet,
            symbolSize: function(data){
                return data[2]/6+10;
            },
            itemStyle: {
                color: function(value){
                    var v1 = Math.round(value.data[0]/100*255);
                    var v2 = Math.round(value.data[1]/100*255);
                    var v3 = Math.round(value.data[2]/100*255);
                    return 'rgb('+v1+','+v2+','+v3+')'
                },
            },
        }],
};
//画图
myChart8.setOption(option8);

var myChart9 = echarts.init(document.getElementById("a9"));
var idata = [{
  value:1,
  name:'1',
}];
var option9 = {
    title: {
        text: '大饼--沈林涛',
    },
    series: [
      {
        type: "pie",
        data: idata,
        label: {
            position: 'inside',
        },
      },
    ],
};
var myInterval = setInterval(function () {
    if (idata.length > 100) {  
      idata = [];
      //停止定时
      // clearInterval(myInterval); 
    } else {
      idata.push({
          value:idata.length,
          name:String(idata.length),
      });
      option9.series[0].data = idata;
      myChart9.setOption(option9);
    }
  }, 100);